# REQUIRES: arm
# RUN: yaml2obj %s -o %t.obj
# RUN: lld-link %t.obj %p/Inputs/library.lib /subsystem:console \
# RUN:   /entry:mainCRTStartup /alternatename:__delayLoadHelper2=mainCRTStartup \
# RUN:   /delayload:library.dll /out:%t.exe
# RUN: llvm-readobj --coff-imports %t.exe | FileCheck -check-prefix=IMPORT %s
# RUN: llvm-readobj --coff-basereloc %t.exe | FileCheck -check-prefix=BASEREL %s
# RUN: llvm-objdump --no-print-imm-hex -d %t.exe | FileCheck --check-prefix=DISASM %s

# IMPORT:      Format: COFF-ARM
# IMPORT-NEXT: Arch: thumb
# IMPORT-NEXT: AddressSize: 32bit
# IMPORT-NEXT: DelayImport {
# IMPORT-NEXT:   Name: library.dll
# IMPORT-NEXT:   Attributes: 0x1
# IMPORT-NEXT:   ModuleHandle: 0x3000
# IMPORT-NEXT:   ImportAddressTable: 0x3008
# IMPORT-NEXT:   ImportNameTable: 0x2040
# IMPORT-NEXT:   BoundDelayImportTable: 0x0
# IMPORT-NEXT:   UnloadDelayImportTable: 0x0
# IMPORT-NEXT:   Import {
# IMPORT-NEXT:     Symbol: function (0)
# IMPORT-NEXT:     Address: 0x40100D
# IMPORT-NEXT:   }
# IMPORT-NEXT: }
#
# BASEREL:      BaseReloc [
# BASEREL-NEXT:   Entry {
# BASEREL-NEXT:     Type: ARM_MOV32(T)
# BASEREL-NEXT:     Address: 0x1000
# BASEREL-NEXT:   }
# BASEREL-NEXT:   Entry {
# BASEREL-NEXT:     Type: ARM_MOV32(T)
# BASEREL-NEXT:     Address: 0x100C
# BASEREL-NEXT:   }
# BASEREL-NEXT:   Entry {
# BASEREL-NEXT:     Type: ARM_MOV32(T)
# BASEREL-NEXT:     Address: 0x1026
# BASEREL-NEXT:   }
# BASEREL-NEXT:   Entry {
# BASEREL-NEXT:     Type: ABSOLUTE
# BASEREL-NEXT:     Address: 0x1000
# BASEREL-NEXT:   }
# BASEREL-NEXT:   Entry {
# BASEREL-NEXT:     Type: HIGHLOW
# BASEREL-NEXT:     Address: 0x3008
# BASEREL-NEXT:   }
# BASEREL-NEXT:   Entry {
# BASEREL-NEXT:     Type: ABSOLUTE
# BASEREL-NEXT:     Address: 0x3000
# BASEREL-NEXT:   }
# BASEREL-NEXT: ]
#
# DISASM:    00401000 <.text>:
# DISASM:      40100c:       f243 0c08       movw r12, #12296
# DISASM-NEXT:               f2c0 0c40       movt    r12, #64
# DISASM-NEXT:               f000 b800       b.w     {{.+}} @ imm = #0
# DISASM-NEXT:               e92d 480f       push.w  {r0, r1, r2, r3, r11, lr}
# DISASM-NEXT:               f20d 0b10       addw    r11, sp, #16
# DISASM-NEXT:               ed2d 0b10       vpush   {d0, d1, d2, d3, d4, d5, d6, d7}
# DISASM-NEXT:               4661            mov     r1, r12
# DISASM-NEXT:               f242 0000       movw r0, #8192
# DISASM-NEXT:               f2c0 0040       movt    r0, #64
# DISASM-NEXT:               f7ff ffe7       bl      0x401000 <.text>
# DISASM-NEXT:               4684            mov     r12, r0
# DISASM-NEXT:               ecbd 0b10       vpop    {d0, d1, d2, d3, d4, d5, d6, d7}
# DISASM-NEXT:               e8bd 480f       pop.w   {r0, r1, r2, r3, r11, lr}
# DISASM-NEXT:               4760            bx      r12

--- !COFF
header:
  Machine:         IMAGE_FILE_MACHINE_ARMNT
  Characteristics: [  ]
sections:
  - Name:            .text
    Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_PURGEABLE, IMAGE_SCN_MEM_16BIT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
    Alignment:       4
    SectionData:     40F20000C0F2000000680047
    Relocations:
      - VirtualAddress:  0
        SymbolName:      __imp_function
        Type:            IMAGE_REL_ARM_MOV32T
symbols:
  - Name:            .text
    Value:           0
    SectionNumber:   1
    SimpleType:      IMAGE_SYM_TYPE_NULL
    ComplexType:     IMAGE_SYM_DTYPE_NULL
    StorageClass:    IMAGE_SYM_CLASS_STATIC
    SectionDefinition:
      Length:          12
      NumberOfRelocations: 1
      NumberOfLinenumbers: 0
      CheckSum:        0
      Number:          1
  - Name:            mainCRTStartup
    Value:           0
    SectionNumber:   1
    SimpleType:      IMAGE_SYM_TYPE_NULL
    ComplexType:     IMAGE_SYM_DTYPE_FUNCTION
    StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
  - Name:            __imp_function
    Value:           0
    SectionNumber:   0
    SimpleType:      IMAGE_SYM_TYPE_NULL
    ComplexType:     IMAGE_SYM_DTYPE_NULL
    StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
...
